package com.fh.rolepermission.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fh.result.ResultObject;
import com.fh.rolepermission.entity.UmsRolePermission;
import com.fh.rolepermission.service.IUmsRolePermissionService;
import com.fh.search.AdminRoleBO;
import com.fh.search.RolePermissionBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author F
 * @since 2021-05-14
 */
@RestController
@RequestMapping("/ums/rolepermission")
public class UmsRolePermissionController {

    @Autowired
    private IUmsRolePermissionService iUmsRolePermissionService;

    @PostMapping
    public ResultObject saveRoleToAdmin(@RequestBody RolePermissionBo rolePermissionBo) {
        iUmsRolePermissionService.saveRoleToAdmin(rolePermissionBo);
        return ResultObject.success();
    }

    @GetMapping("/{roleId}")
    public ResultObject queryRolePermissionAll(@PathVariable("roleId") Long roleId){
        QueryWrapper<UmsRolePermission>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("role_id", roleId);
        List<UmsRolePermission> list=iUmsRolePermissionService.list(queryWrapper);
        return ResultObject.success(list);
    }
}
